/**   
 * @Title: MainActivityExamineFragment.java 
 * @Package cn.edu.scu.healthclient.activity.fragment 
 * @Description: TODO 
 * @author 
 * @date 
 * @version V0.0   
 */
package cn.edu.cdtu.healthclient.activity.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import cn.edu.scu.healthclient.activity.R;

/** 
 * @ClassName: MainActivityExamineFragment 
 * @Description: TODO
 * @author 
 * @date 
 *  
 */
public class MainActivityExamineFragment extends Fragment {

	private TextView topTitle,suggestionTextView;
	private Spinner buweiSpinner,zhengzhuangSpinner;
	int indexOfBuwei=0,indexOfZhengzhuang=0;
	private String zhengzhuang[];
	private String zhengzhuang0[]={"偏头痛","紧张性头痛","鼻窦炎性头痛"};
	private String zhengzhuang1[]={"萎缩性鼻炎","过敏性鼻炎","干燥性鼻炎"};
	private String zhengzhuang2[]={"遗传性敏感皮肤","接触性敏感皮肤","环境刺激性敏感"};
	private  String buwei[]={"头部","鼻子","皮肤"};
	private String suggestion[][]=
		{
			{
				"        前额处跳痛，身体活动时症状加重，头痛症状持续数小时至数天。"
						+ "其他症状还包括：恶心、畏光和视物有光环等。病情较轻时，可服用对乙酰氨基酚和布洛芬。",
						"        头痛并伴有头部压榨感，疼痛可能会延伸至脖颈。"
								+ "持续时间通常为几小时、几天甚至几周。英国伦敦国王学院附属医院头痛病专家安德鲁·"
								+ "道森博士建议，此类头痛发生后，不要急于服药，应尽量采取一些简单的放松治疗，"
								+ "比如，头部或颈部按摩，洗个热水澡等。阿司匹林和布洛芬有一定的治疗作用，"
								+ "但不宜过量服用。",
								"        由鼻窦炎导致的头痛常发生于眼睛上方、脸颊和鼻子周围，多持续性，"
										+ "时间可能长达数周。艾哈迈德博士表示，止痛药和类固醇鼻喷剂对此有一定帮助。"
			},

			{
				"        是一种发展很缓慢的鼻病。此病与内分泌紊乱、神经失调、营养不良等有关。"
						+ "主要表现为鼻子嗅觉消失，鼻腔内有恶臭鼻涕，多为黄绿色脓臭鼻涕。目前尚无特效疗法，"
						+ "每天可用温生理盐水冲洗鼻腔或遵医嘱。",
						"        是受到过敏原刺激所引起的阵发性喷嚏、连续性发作，流大量清水样鼻涕"
								+ "、鼻塞、鼻内发痒等症状。治疗上避免与过敏原接触，口服抗过敏药物及手术疗法。",
								"        多发生在气候干旱地区及高温作业和有粉尘工作环境中的人。"
										+ "治疗时可在鼻腔涂抹红霉素软膏防止黏膜干燥。"
			},

			{
				"        应对策略：选用无香料、无酒精、无防腐剂、无色素、无药物的化妆品，"
						+ "成分越简单越好，并不要频繁更换。在使用新化妆品之前，"
						+ "一定要先在前臂内侧少量试搽3天，如无不适反应方可使用 。",
						"        应对策略：选择不含香精、防腐剂的护肤品，同时最好含有抗自由基的温泉水、"
								+ "棕榈醇、甘油等不刺激皮肤的物质，涂抹后能在皮肤上形成一层隐形的、"
								+ "安全舒适的透明保护膜，使皮肤免受刺激和伤害。",
								"        应对策略：生活调理，主要应注意生活规律，睡眠充足，"
										+ "保持愉快的心情和健康的饮食习惯；饮食调理，多吃蔬菜水果，"
										+ "注意摄取充足的钙质和维生素B和C；少吃辛辣刺激的食物。选择适合的化妆品，"
										+ "特别应该注意皮肤的温和清洁和保湿；远离刺激皮肤的诱因，避免过度按摩，"
										+ "去角质，尽量少化妆或不化妆。"
			}

		};

	/* (non-Javadoc)
	 * <p>Title: onActivityCreated</p> 
	 * <p>Description: </p> 
	 * @param savedInstanceState 
	 * @see android.support.v4.app.Fragment#onActivityCreated(android.os.Bundle)
	 */
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		topTitle = (TextView) getView().findViewById(R.id.topTitle);  
		topTitle.setText("智能导诊");

		buweiSpinner=(Spinner)getView().findViewById(R.id.buwei);
		zhengzhuangSpinner=(Spinner)getView().findViewById(R.id.zhengzhuang);
		suggestionTextView=(TextView)getView().findViewById(R.id.suggestion);

		ArrayAdapter<String> adapter1 =new ArrayAdapter<String>
		(getActivity(),android.R.layout.simple_list_item_multiple_choice,buwei);
		buweiSpinner.setAdapter(adapter1);

		buweiSpinner.setOnItemSelectedListener
		(
				new OnItemSelectedListener()
				{
					public void onItemSelected(AdapterView<?> parent, View view,int pos, long id) 
					{
						switch(pos)
						{
						case 0:
							zhengzhuang=zhengzhuang0;
							indexOfBuwei = 0;
							break;
						case 1:
							zhengzhuang=zhengzhuang1;
							indexOfBuwei = 1;
							break;
						case 2:
							zhengzhuang=zhengzhuang2;
							indexOfBuwei = 2;
							break;
						default:
							break;
						}
						ArrayAdapter<String> adapter2=new ArrayAdapter<String>
						(getActivity(),android.R.layout.simple_list_item_multiple_choice,zhengzhuang);
						zhengzhuangSpinner.setAdapter(adapter2);
					}
					public void onNothingSelected(AdapterView<?> arg0){}
				}
				);

		zhengzhuangSpinner.setOnItemSelectedListener
		(
				new OnItemSelectedListener()
				{
					public void onItemSelected(AdapterView<?> arg0, View arg1,int pos, long id) 
					{
						switch(pos)
						{
						case 0:
							indexOfZhengzhuang=0;
							break;
						case 1:
							indexOfZhengzhuang=1;
							break;
						case 2:
							indexOfZhengzhuang=2;
							break;
						default:
							break;
						}
						suggestionTextView.setText(suggestion[indexOfBuwei][indexOfZhengzhuang]);
					}
					public void onNothingSelected(AdapterView<?> arg0) {}
				}
				);
	}

	/* (non-Javadoc)
	 * <p>Title: onCreateView</p> 
	 * <p>Description: </p> 
	 * @param inflater
	 * @param container
	 * @param savedInstanceState
	 * @return 
	 * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
	 */
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		return inflater.inflate(R.layout.activity_main_examine_fragment, container, false);
	}



}
